import axios from 'axios'

class httpCore {
  // demo Rest
  p4000CfmBCo (data) {
    return axios({url: 'rest/v1/acceptance/p4000CfmBCo', data, method: 'post'})
  }
}

//  add request interceptors
axios.interceptors.request.use(
  function (config) {

    return config
  },
  function (error) {
    // request error do something
    console.log(error)
    return Promise.reject(error)
  })

// add response interceptors
axios.interceptors.response.use(
  function (response) {

    return response
  },
  function (error) {
    //  error do something
    if (error.message === 'Network Error' && window.location.href.indexOf('/NetErr') === -1) {
      window.vm.$tips.showToast('网络异常，请检查网络后重试!')
      return
    }
    return Promise.reject(error)
  }
)

export default httpCore
